package leetcode.median;

import leetcode.base.ListNode;

/**
 * ClassName: $83_DeleteDuplicates
 * Description:
 * date: 2022-02-17 20:53
 *
 * @author liyifan
 */
public class $83_DeleteDuplicates {
    public ListNode deleteDuplicates(ListNode head) {
        if (head == null || head.next == null) {
            return head;
        }
        ListNode pre = head;
        ListNode cur = head.next;
        while (cur != null) {
            if (pre.val == cur.val) {
                ListNode next = cur.next;
                pre.next = next;
                cur = next;
            } else {
                pre = pre.next;
                cur = cur.next;
            }
        }
        return head;
    }
}
